<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "{{%help}}".
 *
 * @property integer $id
 * @property integer $cat_id
 * @property string $title
 * @property string $key_word
 * @property string $info
 * @property string $content
 */
class Help extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%help}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['cat_id', 'title', 'content'], 'required'],
            [['cat_id'], 'integer'],
            [['content'], 'string'],
            [['title', 'key_word'], 'string', 'max' => 255],
            [['info'], 'string', 'max' => 500],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('app', 'ID'),
            'cat_id' => Yii::t('app', '分类'),
            'title' => Yii::t('app', '标题'),
            'key_word' => Yii::t('app', '关键词'),
            'info' => Yii::t('app', '描述'),
            'content' => Yii::t('app', '内容'),
        ];
    }

    public function getCat(){
        return $this->hasOne(HelpCat::className(),['id'=>'cat_id']);
    }
}
